fix: cache validation, narrow invalidation, ISR pre-render, robust CI redis wait (#1099, #1100, #1101, #1102) - #1152
Merged
nanaf6203-bit merged 2 commits intoSep 28, 2026
Conversation
…y pages, robust CI redis wait Resolves the four issues assigned to Mirabel64: - MettaChain#1101: validate Redis cache payloads against zod schemas before trusting them; corrupted/stale entries are discarded and counted as invalid + miss instead of being cast to Property/SearchResult. - MettaChain#1100: add a per-property key index so mutations evict only the detail, listing and search keys that embed the affected property; full flush is now explicit. Document the hit-rate impact in docs/cache-api.md. - MettaChain#1102: generateStaticParams now returns real featured property ids so the popular detail pages are pre-rendered; the rest stay on-demand + ISR. - MettaChain#1099: replace the fragile `docker --filter ancestor` redis wait with a deterministic published-port/name lookup and actionable failure logs. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
|
@Mirabel64 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Resolves the four open issues assigned to @Mirabel64 in one PR.
Closes #1099
Closes #1100
Closes #1101
Closes #1102
Changes
#1102 — Pre-generate popular property IDs in
generateStaticParamssrc/lib/propertyServiceServer.ts: newgetPopularPropertyIds(limit = 20)that returns featured property ids (falling back to the full catalogue when nothing is flagged featured).src/app/properties/[id]/page.tsx:generateStaticParamsnow returns real{ id }entries instead of[].dynamicParamsstays default (true), so non-listed ids are still generated on demand and revalidated by ISR (revalidate = 60).#1101 — Validate JSON parsed from Redis before trusting cached payloads
src/types/propertySchemas.ts: new zod schemas mirroring thePropertydomain types (propertySchema,propertySearchResultSchema,autocompleteResultsSchema,cacheStatsSchema).src/lib/redisCache.ts: everyJSON.parseof a cache payload now goes throughparseCached, which validates against a schema. Malformed or shape-mismatched entries are discarded (treated as a miss) instead of being cast toProperty/SearchResult. Failures are logged and counted (cache:hit_rate:invalid, exposed asinvalidingetStats).#1100 — Property updates no longer flush the entire cache
src/lib/redisCache.ts: writes maintain a per-property reverse index (index:property:<id>), andinvalidatePropertydeletes only the keys that embed that property, falling back to the old narrow pattern scan only when the index is missing. Also fixedinvalidatePattern, whoseDELargs were double-prefixed by ioredis and silently missed.src/lib/blockchainCacheInvalidator.ts: only membership-changing events (PropertyCreated,PropertyDelisted) flushlisting:*/search:*; updates use the narrow index path.src/app/api/properties/route.ts:POSTinvalidates narrowly when an id is present, otherwise a listing/search flush.docs/cache-api.md: documented the new behaviour plus before/after hit-rate notes.#1099 — Harden the Redis wait step in CI
.github/workflows/ci.yml: replaced the fragiledocker ps --filter ancestor=redis:7-alpinelookup with a deterministic lookup by published port (then service name), a bounded 30×2s retry, and a clear failure path that dumpsdocker ps -aand container logs.Tests
src/lib/__tests__/redisCache.test.ts: added poisoned-payload rejection, malformed listing rejection, stats shape (includinginvalid), and a narrow-invalidation test asserting an unrelated listing survives an update.src/lib/__tests__/propertyServiceServer.test.ts: assertsgetPopularPropertyIdsreturns real, pre-renderable ids and respects the limit.Typecheck shows no new errors versus
main(the repo has pre-existing errors in this environment's stalenode_modules; a before/after diff oftscoutput is unchanged apart from line-number shifts).Notes